package com.six.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum RoleEnum {
    CUSTOMER(1, "CUSTOMER"),
    WAITER(2, "WAITER"),
    MANAGER(3, "MANAGER"),
    ADMIN(4, "ADMIN");

    private final Integer id;
    private final String authority;

    public static RoleEnum fromId(Integer id) {
        for (RoleEnum role : values()) {
            if (role.getId().equals(id)) {
                return role;
            }
        }
        throw new IllegalArgumentException("Invalid role id: " + id);
    }
}